<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小球动画</title>
    <style>
        button {
            width: 80px;
            height: 30px;
            display: block;
        }
        .ball {
            width: 20px;
            height: 20px;
            background-color: red;
            border-radius: 10px;
        }
        .target {
            position: absolute;
            left: 100px;
            top: 300px;
            width: 100px;
            height: 100px;
            background-color: red;
        }
    </style>
</head>
<body>
    <button id="btn">小球</button>
    <div class="target"></div>
    <script>

        let btn = document.getElementById('btn')
        // function genBall() {
        //     console.log('xx');
        // }
        let px = 100
        let py = 200
        btn.addEventListener('click', () => {
            let ball = document.createElement('div')
            px += 10
            py += 20
            ball.classList.add('ball')
            // ball.style.transform = `translate(${px}px,${py}px)`
            ball.style.transfrom = `translate(${px}px, ${py}px)`
            ball.style.transition = '1s all ease'
            document.body.appendChild(ball)
        })
        function animate(target) {
           
        }
    </script>
</body>
</html>